package com.zcf.controller;


import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zcf.common.json.Body;
import com.zcf.pojo.Activity;
import com.zcf.service.ActivityServiceImpl;
import com.zcf.vo.out.LayuiJson;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZhaoQi
 * @since 2019-06-15
 */
@CrossOrigin
@Controller
@RequestMapping("/activity")
public class ActivityController {
	@Autowired
	ActivityServiceImpl activityServiceImpl;
	/**
	 * 后端添加活动
	 * @param activity
	 * @return
	 */
	@PostMapping("add")
	@ResponseBody
	public Body add(Activity activity){
		return activityServiceImpl.add(activity);
	}
	/**
	 * 获取活动
	 * @param activity
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@PostMapping("getactivity")
	@ResponseBody
	public LayuiJson getactivity(Activity activity,@RequestParam(value = "pageNum") int pageNum,
			@RequestParam(value = "pageSize") int pageSize){
		return activityServiceImpl.getactivity(activity,pageNum,pageSize);
	}
	/**
	 * 修改活动
	 * @param activity
	 * @return
	 */
	@PostMapping("editactivity")
	@ResponseBody
	public Body editactivity(Activity activity){
		return activityServiceImpl.editactivity(activity);
	}
	/**
	 * 删除活动
	 * @param activity
	 * @return
	 */
	 @PostMapping("delactivity")
	 @ResponseBody
	 public Body delactivity(Activity activity){
		 return activityServiceImpl.delactivity(activity);
	 }
	 /**
	  * 获取活动标题
	  * @param activity
	  * @return
	  */
	 @PostMapping("gettitle")
	 @ResponseBody
	 public Body gettitle(Activity activity){
		 return activityServiceImpl.gettitle(activity);
	 }
	/**
	 * 根据标题获取内容
	 * @param activity
	 * @return
	 */
	 @PostMapping("getcontent")
	 @ResponseBody
	 public Body getcontent(Activity activity){
		 return activityServiceImpl.getcontent(activity);
	 }
	 
}

